home *** CD-ROM | disk | FTP | other *** search
/ NeXT Education Software Sampler 1992 Fall / NeXT Education Software Sampler 1992 Fall.iso / Programming / Source / IP_Pvc / Pvc_Control.m < prev    next >
Encoding:
Text File  |  1992-05-22  |  2.4 KB  |  113 lines

  1.  
  2. /* Generated by Interface Builder */
  3. #import <appkit/appkit.h>
  4. #import "Pvc_Document.h"
  5. #import "Pvc_Control.h"
  6.  
  7. @implementation Pvc_Control
  8.  
  9. -newFrom:sender
  10. {
  11.     [Pvc_Document new];  // May want to put it in its own zone
  12.     return self;
  13. }
  14.  
  15. static id documentInWindow(id window)
  16. /*
  17.  * Checks to see if the passed window's delegate is a DrawDocument.
  18.  * If it is, it returns that document, otherwise it returns nil.
  19.  */
  20. {
  21.     id document = [window delegate];
  22.     return [document isKindOf:[Pvc_Document class]] ? document : nil;
  23. }
  24.  
  25. static id openFile(const char *directory, const char *name, BOOL display)
  26. /*
  27.  * Opens a file with the given name in the specified directory.
  28.  * If we already have that file open, it is ordered front.
  29.  * Returns the document if successful, nil otherwise.
  30.  */
  31. {
  32.     char buffer[MAXPATHLEN+1], path[MAXPATHLEN+1];
  33.  
  34.     if (name && *name) {
  35.     if (!directory) {
  36.         directory = ".";
  37.     } else if (*directory != '/') {
  38.         strcpy(buffer, "./");
  39.         strcat(buffer, directory);
  40.         directory = buffer;
  41.     }
  42.     if (!chdir(directory) && getwd(path)) {
  43.         strcat(path, "/");
  44.         strcat(path, name);
  45.         return [Pvc_Document newFromFile:path];
  46.     } else {
  47.         NXRunAlertPanel("Open", "Invalid path: %s", "OK", NULL, NULL, directory);
  48.     }
  49.     }
  50.  
  51.     return nil;
  52. }
  53.  
  54. - openFrom:sender
  55. /*
  56.  * Called by pressing Open... in the Window menu.
  57.  */
  58. {
  59. #if 0
  60.  
  61.     static int haveOpenedDocument = 0;
  62.     static char directory[1024] = {0};
  63.     const char *const *files;
  64.     static const char *const sndType[2] = {"snd", NULL};
  65.     id openpanel = [[OpenPanel new] allowMultipleFiles:YES];
  66.  
  67.     if (directory && (*directory == '/')) [openpanel setDirectory:directory];
  68.     if ([openpanel runModalForTypes:sndType]) {
  69.     files = [openpanel filenames];
  70.     directory = (char *)[openpanel directory];
  71.     while (files && *files) {
  72.         haveOpenedDocument = openFile(directory, *files, YES) || haveOpenedDocument;
  73.         files++;
  74.     }
  75.     }
  76.    fprintf(stderr,"Not implemented yet\n");
  77.    return self;
  78.  
  79. #endif
  80. }
  81.  
  82. -saveFrom:sender
  83. {
  84.    fprintf(stderr,"Not implemented yet\n");
  85.    return self;
  86. }
  87.  
  88. -saveAsFrom:sender
  89. {
  90.    fprintf(stderr,"Not implemented yet\n");
  91.    return self;
  92. }
  93.  
  94. -closeFrom:sender
  95. {
  96.    fprintf(stderr,"Not implemented yet\n");
  97.    return self;
  98. }
  99.  
  100. - info:sender
  101.     /* Display the info panel, unarchiving it if necessary. */
  102. {
  103.     if (!infoPanel) {
  104.     infoPanel = [self loadNibSection:"info.nib" owner:self withNames:NO];
  105.     [infoPanel center];
  106.     }
  107.     [infoPanel orderFront:self];
  108.  
  109.     return self;
  110. }
  111.  
  112. @end
  113.